/**
 * shuoGG-Ajax-Utils
 * */

function ajaxSendGet(dstUrl) {
	var xmlHttp = createXMLHttpRequest();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var person;
			var jsonStr = xmlHttp.responseText;
			person = eval("(" + jsonStr + ")"); //解析json为js对象
			alert(person.name);
		}
	};
	xmlHttp.open("GET", dstUrl, true);
	xmlHttp.send(null);
}

function ajaxSendPost(dstUrl, respBody) {
	var xmlHttp = createXMLHttpRequest();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			alert(xmlHttp.responseText);
		}
	};
	xmlHttp.open("POST", dstUrl, true);
	xmlHttp.setRequestHeader("Content-Type",
			"application/x-www-form-urlencoded");
	xmlHttp.send(respBody);
}

function ajaxSendDyn(dstUrl, jsonDisposeFunc) {
	var xmlHttp = createXMLHttpRequest();
	xmlHttp.onreadystatechange = function() {
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			var person;
			var jsonStr = xmlHttp.responseText;
			person = eval("(" + jsonStr + ")"); //解析json为js对象
			jsonDisposeFunc(person);
		}
	};
	xmlHttp.open("GET", dstUrl, true);
	xmlHttp.send(null);
}


function createXMLHttpRequest() {
	var xmlHttp;
	try {
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
			}
		}
	}
	return xmlHttp;
}
